package com.geeklei.media.ui.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class BatteryStatusIconView extends ImageView {
    private boolean mCharging = false;
    private boolean mDisabled;
    private boolean mEnableDarkMode = false;
    private int mIconLevel;

    public BatteryStatusIconView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public void setImageLevel(int i) {
        this.mIconLevel = i;
        super.setImageLevel(i);
        invalidate();
    }

    public void setImageResource(int i) {
    }

    public void updateCharging(boolean z) {
        this.mCharging = z;
        setImageDrawable(getIcon());
        setImageLevel(this.mIconLevel);
    }

    protected Drawable getIcon() {
        return this.mCharging ?
                this.mEnableDarkMode ? BatteryIcon.getInstance(getContext().getApplicationContext()).getGraphicChargeIconDarkMode(this.mIconLevel) : BatteryIcon.getInstance(getContext().getApplicationContext()).getGraphicChargeIcon(this.mIconLevel)
                :
                this.mEnableDarkMode ?
                        BatteryIcon.getInstance(getContext().getApplicationContext()).getGraphicIconDarkMode(this.mIconLevel) : BatteryIcon.getInstance(getContext().getApplicationContext()).getGraphicIcon(this.mIconLevel);
    }

    public void disable(boolean z) {
        if (this.mDisabled != z) {
            this.mDisabled = z;
            updateVisibility();
        }
    }

    protected void updateVisibility() {
        setVisibility(!this.mDisabled ? VISIBLE : GONE);
    }
}
